<?php
namespace App;

use Illuminate\Database\Eloquent\Model;

class DataOrder extends Model
{
    protected $table = 'data_order';

    protected $year = '2019';

    //通过构造函数设置对应年份，后续的数据处理通过程序
    //后面借助mycat解决
    public function __construct(array $attributes = [], $year = null)
    {
        empty($year) ? $this->setTable('data_order_'.$this->year) : $this->setTable('data_order'.$year);
        parent::__construct($attributes);
    }

    public function test_2018()
    {
        $order = new DataOrder();
        return $order->get()->toArray();
    }

    public function test_2019()
    {
        $order = new DataOrder();
        return $order->get()->toArray();
    }

}
